noremap <silent> ge gj
noremap <silent> gu gk
noremap <silent> b B
noremap <silent> B b
noremap <silent> w W
noremap <silent> W w
noremap l u
noremap L <C-r>
noremap k n
noremap K N
noremap j e
noremap J E
noremap <silent> ]p p
noremap <silent> p ]p
noremap <silent> n h
noremap <silent> N ^
noremap <silent> I $
noremap <silent> i l
noremap <silent> h i
noremap <silent> u k
noremap <silent> <A-u> <nop>
nnoremap <silent> U 10k
vnoremap <silent> U 3k
noremap <silent> e j
noremap <silent> <A-e> <nop>
nnoremap <silent> E 10j
vnoremap <silent> E 3j
noremap <silent> H I
noremap <silent> <LEADER>ay ggyG
noremap <silent> <LEADER>ad ggdG
noremap <silent> <LEADER>ap ggVGP
noremap <silent> <LEADER>qn @n
noremap <silent> qq @n
noremap <silent> <LEADER>e :e!<CR>
noremap <A-f> /
noremap <silent> <LEADER><LEADER> <Esc>/>++><CR>:nohlsearch<CR>c4l
inoremap <silent> tn<LEADER> >++>
noremap <silent> <LEADER>ll :set cursorcolumn<CR>
nnoremap <silent> - <C-o>
nnoremap = <C-i>
cnoremap <A-f> /
noremap s <leader><leader>/
inoremap <A-o> <nop>
noremap <silent> <LEADER>ta :tabe<CR>

nnoremap <silent> <up> :res +5<CR>
nnoremap <silent> <down> :res -5<CR>
nnoremap <silent> <left> :vertical resize -5<CR>
nnoremap <silent> <right> :vertical resize +5<CR>
noremap <silent> <LEADER>ww :w !sudo tee %<CR>
nnoremap <LEADER>coc :set splitright<CR>:vsplit<CR>:CocConfig<CR>
noremap <silent> ? *
" noremap!   <Esc>
nnoremap > >>
nnoremap < <<
nnoremap <LEADER>lg :call system('st -e sh -c lazygit')<cr>
nnoremap <silent> <LEADER>ff :silent Vifm<CR>
nnoremap <silent> <LEADER>d <C-]>
" fold and unfold {{{
noremap <LEADER>o za
noremap <LEADER>zf :call Fold()<CR>
function! Fold()
    if &filetype=='cpp'
        exec 'normal! zfa{'
    else
        exec 'normal! zfip'
    endif
endfunction
" }}}

" markdown shortcut key {{{
autocmd Filetype markdown inoremap <buffer> <silent> ;,
autocmd Filetype markdown inoremap <buffer> <silent> ;f <Esc>/<++><CR>:nohlsearch<CR>c4l
autocmd Filetype markdown nnoremap <buffer> <silent> ;f <Esc>/<++><CR>:nohlsearch<CR>c4l
autocmd Filetype markdown inoremap <buffer> <silent> ;s <Esc>/ <++><CR>:nohlsearch<CR>c5l
autocmd Filetype markdown inoremap <buffer> <silent> ;- ---<Enter><Enter>
autocmd Filetype markdown inoremap <buffer> <silent> ;b **** <++><Esc>F*hi
autocmd Filetype markdown inoremap <buffer> <silent> ;x ~~~~ <++><Esc>F~hi
autocmd Filetype markdown inoremap <buffer> <silent> ;x ** <++><Esc>F*i
autocmd Filetype markdown inoremap <buffer> <silent> ;q `` <++><Esc>F`i
autocmd Filetype markdown inoremap <buffer> <silent> ;c ```<Enter><++><Enter>```<Enter><Enter><++><Esc>4kA
autocmd Filetype markdown inoremap <buffer> <silent> ;g - [ ] <Enter><++><ESC>kA
autocmd Filetype markdown inoremap <buffer> <silent> ;u <u></u><++><Esc>F/hi
autocmd Filetype markdown inoremap <buffer> <silent> ;p ![](<++>) <Enter><++><Esc>kF[a
autocmd Filetype markdown inoremap <buffer> <silent> ;a [](<++>) <++><Esc>F[a
autocmd Filetype markdown inoremap <buffer> <silent> ;1 #<Space><Enter><++><Esc>kA
autocmd Filetype markdown inoremap <buffer> <silent> ;2 ##<Space><Enter><++><Esc>kA
autocmd Filetype markdown inoremap <buffer> <silent> ;3 ###<Space><Enter><++><Esc>kA
autocmd Filetype markdown inoremap <buffer> <silent> ;4 ####<Space><Enter><++><Esc>kA
autocmd Filetype markdown inoremap <buffer> <silent> ;t <C-R>=strftime("%Y-%m-%d %H:%M:%S")<CR>
" }}}

" register yank and paste {{{
noremap <LEADER>pn "np
noremap <LEADER>pe "ep
noremap <LEADER>pi "ip
vnoremap <LEADER>yn "ny
vnoremap <LEADER>ye "ey
vnoremap <LEADER>yi "iy
vnoremap  <Esc>
" }}}

noremap! tna 1
noremap! tnr 2
noremap! tns 3
noremap! tnt 4
noremap! tnd 5
noremap! tnh 6
noremap! tnn 7
noremap! tne 8
noremap! tni 9
noremap! tno 0
noremap! tnA !
noremap! tnR @
noremap! tnS #
noremap! tnT $
noremap! tnD %
noremap! tnH ^
noremap! tnN &
noremap! tnE *
noremap! tnI (
noremap! tnO )

noremap! aoa !
noremap! aor @
noremap! aos #
noremap! aot $
noremap! aod %
noremap! aoh ^
noremap! aon &
noremap! aoe *
noremap! aoi (
noremap! aoo )

noremap! tn<Enter> \n
noremap! tnl ()<left>
noremap! tnu []<left>
noremap! tny <Esc>$a{}<left>
noremap! tnY {}<left>
noremap!  <Esc>

